import { Component } from "react";

export default class From extends Component {
    constructor() {
        super()
        this.state = {
        }
    }
    changeInput = (event) => {
        this.props.change(event)
    }
    add = () => {
        let obj = { id: +new Date(), user: this.props.statec.user, age: this.props.statec.age };
        this.props.add(obj)
    }
    editOK = () => {
        this.props.editOK()
    }
    render() {
        return (
            <form>
                <div>
                    <input type="text" value={this.props.statec.user} name="user" onChange={this.changeInput} /></div>
                <div>
                    <input type="text" value={this.props.statec.age} name="age" onChange={this.changeInput} /></div>
                <div>
                    {
                        this.props.statec.flag? <input type="button" value="提交" onClick={this.add} /> : <input type="button" value="确认修改" onClick={this.editOK} />
                    }
                </div>
            </form>
        )
    }
}